package com.qf.listener;

import com.event.util.EventHandler;
import com.event.util.EventType;
import com.feign.HotalFeign;
import com.qf.entity.Room;
import com.qf.entity.RoomPrice;
import com.qf.service.ISearchService;
import com.qf.util.EventTypeContact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@EventType(EventTypeContact.UPDATE_PRICE)
public class PriceUpdateHandler implements EventHandler<RoomPrice> {

    @Autowired
    private ISearchService searchService;

    @Autowired
    private HotalFeign hotalFeign;

    @Override
    public void msgHandler(RoomPrice roomPrice) {
        System.out.println("接收到房间价格修改信息：" + roomPrice);
        //通过房间id查询酒店信息
        Room room = hotalFeign.getRoomById(roomPrice.getRid()).getData();
        searchService.updateRoomPrice(room.getHid(), roomPrice);
    }
}
